<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .conter{
            display: flex;
            flex-direction: column;
        }
        img{
            width: 300px;
            height: 300px;
        }
    </style>
</head>
<body>
    <div class="conter">
        <img src="./imgs/loading.gif" data-src="./imgs/1.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/2.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/3.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/4.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/5.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/1.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/2.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/3.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/4.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/5.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/1.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/2.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/3.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/4.jpg">
        <img src="./imgs/loading.gif" data-src="./imgs/5.jpg">
    </div>
    <script>
        let imgs = document.querySelectorAll('img');
        function Loadimg(){
            imgs.forEach(item => {
                if (item.offsetTop < window.innerHeight + window.scrollY){
                    item.src = item.getAttribute('data-src')
                }
            })
        }
        Loadimg()
        window.onscroll = function(){
            Loadimg()
        }
   </script>
</body>
</html>